class Content < ActiveRecord::Base
  has_many :meta_datas
  has_many :page_elements, :dependent => :destroy
  has_many :pages, :through => :page_elements
  
  
  def body_to_html
    case content_type
      when "text/textile"
        if body.blank?
          ""
        else
          textilized = RedCloth.new(body)#, [ :hard_breaks ])
#          textilized.hard_breaks = true if textilized.respond_to?("hard_breaks=")
          textilized.to_html
        end
      when "text/html"
        body
      else
        body
    end
  end
  def title
    truncate strip_html( body )
  end
end
